import { get, post } from '@/utils/http'

enum API {
  // 发布消息
  PUBLISHMESSAGE_API = '/message/publishMessage',
  // 获取消息列表
  GETMESSAGELIST_API = '/message/getMessageList',
  // 编辑消息
  EDITMESSAGE_API = '/message/editMessage',
  // 根据发布部门筛选消息
  SEARCHMESSAGEBYDEPARTMENT_API = '/message/searchMessageByDepartment',
  // 根据发布等级筛选消息
  SEARCHMESSAGEBYLEVEL_API = '/message/searchMessageByLevel',
  // 多条件查询
  SEARCHMESSAGE_API = '/message/searchMessage',
  // 获取详细信息
  GETMESSAGE_API = '/message/getMessage',
  // 更新点击率
  UPDATECLICK_API = '/message/updateClick',
  // 放入回收站
  FIRSTDELETE_API = '/message/firstDelete',
  // 获取回收站列表
  GETRECYCLILIST_API = '/message/getRecycliList',
  // 还原
  RECOVER_API = '/message/recover',
  //彻底删除
  DELETEMESSAGE_API = '/message/deleteMessage'
}
// 发布消息
export const publishMessageAPI = (data: Message) => {
  return post<void>(API.PUBLISHMESSAGE_API, data)
}
// 获取消息列表
export const getMessageListAPI = (page: number, message_category: string) => {
  return get<Message[]>(API.GETMESSAGELIST_API, { params: { page, message_category } })
}
// 编辑消息
export const editMessageAPI = (data: Message) => {
  return post<void>(API.EDITMESSAGE_API, data)
}
// 根据发布部门筛选消息
export const searchMessageByDepartmentAPI = (page: number, message_publish_department: string) => {
  return get<Message[]>(API.SEARCHMESSAGEBYDEPARTMENT_API, {
    params: { page, message_publish_department }
  })
}
// 根据发布等级筛选消息
export const searchMessageByLevelAPI = (
  page: number,

  message_level: string
) => {
  return get<void>(API.SEARCHMESSAGEBYLEVEL_API, { params: { page, message_level } })
}
// 多条件查询
export const searchMessageAPI = (
  page: number,
  message_publish_department: string,
  message_level: string
) => {
  return get<void>(API.SEARCHMESSAGE_API, {
    params: { page, message_publish_department, message_level }
  })
}
// 获取详细信息
export const getMessageAPI = () => {
  return get<void>(API.GETMESSAGE_API)
}
// 更新点击率
export const updateClickAPI = (message_click_number: number, id: number) => {
  return post<void>(API.UPDATECLICK_API, { message_click_number, id })
}
// 放入回收站
export const firstDeleteAPI = (id: number) => {
  return post<void>(API.FIRSTDELETE_API, { id })
}
// 获取回收站列表
export const getRecycliListAPI = (page: number) => {
  return get<Message[]>(API.GETRECYCLILIST_API, { params: { page } })
}
// 还原
export const recoverAPI = (id: number) => {
  return post<void>(API.RECOVER_API, { id })
}
//彻底删除
export const deleteMessageAPI = (id: number) => {
  return post<void>(API.DELETEMESSAGE_API, { id })
}
